import com.google.gson.Gson;
import meta.MTConfig;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class Main {

    public static void main(String[] args) {
//        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//        System.out.println("==Please input password==：");
//        try {
//            String pass = in.readLine();
//            System.out.print("PassWord is : " + pass);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }

        File dir = new File("E:\\WorkGround\\Intellij Project\\Java\\MTGenerator\\asProjectFolder\\dialog");
        File[] files = dir.listFiles();
        for (int i = 0; i < files.length; i++) {
            if (files[i].isDirectory()) {
                loopToFindMoudleCreateHelper(files[i]);
            }
        }
    }

    /**
     * ��ȡConfig�ļ�
     */
    private static MTConfig getJsonConfig() {
        File f = new File("Config.json");
        Gson gson = new Gson();
        String configSTR = "";
        BufferedReader reader = null;
        try {
            reader = new BufferedReader(new FileReader(f));
            String tempString = null;
            while ((tempString = reader.readLine()) != null) {
                configSTR += tempString;
            }
            reader.close();
        } catch (IOException e) {
            System.err.println("Can not load Config.json file , check is this with jar at the same folder");
        }
        return gson.fromJson(configSTR, MTConfig.class);
    }


    private static void loopToFindMoudleCreateHelper(File directorFile) {
        String directoryName = directorFile.getName();
        String first = directoryName.substring(0, 1).toUpperCase();
        String rest = directoryName.substring(1, directoryName.length());
        String moudleCreateHelperName = new StringBuffer(first).append(rest).toString() + "MoudleCreateHelper.as";


        File[] files = directorFile.listFiles();
        for (int i = 0; i < files.length; i++) {
            File subFile = files[i];
            if (!subFile.isDirectory() && subFile.getName().equals(moudleCreateHelperName)) {
                System.out.printf("找到Moudle:" + moudleCreateHelperName);
                System.out.println("");
            }
        }
    }

}
